//
//  GMExeTabCell.m
//  Teecloud
//
//  Created by 小熊 on 2018/11/9.
//  Copyright © 2018年 小志. All rights reserved.
//

#import "GMExeTabCell.h"
#import "GMSubjectsItem.h"
@interface GMExeTabCell()
@property (weak, nonatomic) IBOutlet UIButton *choseBtn;
@property (weak, nonatomic) IBOutlet UILabel *content;

@end
@implementation GMExeTabCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.choseBtn.layer.borderWidth=1.0;
    self.choseBtn.layer.cornerRadius = 7.5;
    self.choseBtn.layer.borderColor = kDarkGrayColor.CGColor;
}
-(void)setModel:(GMSubjectsItem *)model{
    _model = model;
    NSDictionary *options = @{NSDocumentTypeDocumentAttribute:NSHTMLTextDocumentType,NSFontAttributeName:@14};
    NSData *data = [model.Content dataUsingEncoding:NSUnicodeStringEncoding];
    NSMutableAttributedString *attri = [[NSMutableAttributedString alloc] initWithData:data options:options documentAttributes:nil error:nil];
    NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
    style.lineSpacing=0;
    style.paragraphSpacing=0;
    [attri addAttribute:NSParagraphStyleAttributeName value:style range:NSMakeRange(0, attri.length)];
    self.content.attributedText = attri;
    CGSize size = [self.content sizeThatFits:CGSizeMake(DEVICE_WIDTH-65, 1000)];
    if (size.height <20) {
        model.cellHight = 45;
    }else{
        model.cellHight =size.height+15;
    }
    switch (model.SortNo) {
        case 0:{
            [self.choseBtn setTitle:@"A" forState:UIControlStateNormal];
        }
            break;
        case 1:{
             [self.choseBtn setTitle:@"B" forState:UIControlStateNormal];
        }
            break;
        case 2:{
             [self.choseBtn setTitle:@"C" forState:UIControlStateNormal];
        }
            break;
        case 3:{
             [self.choseBtn setTitle:@"D" forState:UIControlStateNormal];
        }
            break;
        case 4:{
             [self.choseBtn setTitle:@"E" forState:UIControlStateNormal];
        }
            break;
            
        default:
            break;
    }
    if (model.selected) {
        [self.choseBtn setTitleColor:kWhiteColor forState:UIControlStateNormal];
        self.choseBtn.backgroundColor = [UIColor colorWithHexString:@"007AFF"];
        self.choseBtn.layer.borderColor = [UIColor colorWithHexString:@"007AFF"].CGColor;
    }else{
        [self.choseBtn setTitleColor:kDarkGrayColor forState:UIControlStateNormal];
        self.choseBtn.backgroundColor = kWhiteColor;
        self.choseBtn.layer.borderColor = kDarkGrayColor.CGColor;
       
    }
}

@end
